<?php
// $Id: Controller.php 27 2010-11-16 12:49:54Z mjohnson60@gmail.com $


Loader::import('View');

/**
 * Enter description here ...
 * 
 * @author Mark Phillip Johnson
 * @version 1.0
 * @copyright Copyright (c) 2010, markjohnson
 * @license http://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
 *
 */
class Controller extends Object
{
	/**
	 * Enter description here ...
	 * 
	 * @var Controller
	 */
	private static $instance = NULL;
	
	/**
	 * Enter description here ...
	 * 
	 * @var string
	 */
	var $name = NULL;
	
	/**
	 * Enter description here ...
	 * 
	 * @var string
	 */
	private $title = NULL;
	
	/**
	 * Enter description here ...
	 * 
	 * @var Config
	 */
	var $config;
	
	/**
	 * Enter description here ...
	 * 
	 * @var Db
	 */
	var $db;
	
	/**
	 * Enter description here ...
	 * 
	 * @var Storage
	 */
	var $store;
	
	/**
	 * Enter description here ...
	 * 
	 * @var Loader
	 */
	var $loader;
	
	/**
	 * Enter description here ...
	 * 
	 * @var View
	 */
	var $view;

	/**
	 * Enter description here ...
	 * 
	 */
	public function __construct()
	{
		self::$instance = & $this;
		
		parent::__construct();
		
		$this->config = & Config::getInstance();
		$this->db = & Db::getInstance();
		$this->store = & Storage::getInstance();
		$this->loader = & Loader::getInstance();
	}

	/**
	 * Enter description here ...
	 * 
	 * @return boolean|NULL
	 */
	public static function &getInstance()
	{
		if (!isset(self::$instance))
		{
			return FALSE;
		}
		
		return self::$instance;
	}

	/**
	 * @return the $title
	 */
	public function getTitle()
	{
		return $this->title;
	}

	/**
	 * @param string $title
	 */
	public function setTitle(string $title)
	{
		$this->title = $title;
		$this->view->title = $this->title;
	}

	/**
	 * @return the $view
	 */
	public function getView()
	{
		return $this->view;
	}

	/**
	 * @param View $view
	 */
	public function setView(View $view)
	{
		if ($view instanceof View)
		{
			$this->view = $view;
		}
	}

	/**
	 * Enter description here ...
	 * 
	 * @return View
	 */
	public function loadView()
	{
		$view = new View();
		
		return $view;
	}

	/**
	 * Enter description here ...
	 * 
	 */
	public function viewDidLoad()
	{
	
	}
}
